package implementor;

import daoInterface.CardDao;
import dbhandeling.Crude;
import dto.Card;

public class CardDaoImplementor extends Crude implements CardDao
{
String className=new Card().getClass().getName();
@Override
public void add(Card card) throws Exception
{
insert(card);
}
/***********************************************************/
@Override
public void update(Card card) throws Exception
{
super.update(className,"customerName",card.getCustomerName()+"","autoCardId",card.getAutoCardId()+"");
super.update(className,"referenceNo",card.getReferenceNo()+"","autoCardId",card.getAutoCardId()+"");
super.update(className,"paymentMethodId",card.getPaymentMethodId()+"","autoCardId",card.getAutoCardId()+"");
super.update(className,"transPaymentId",card.getTransPaymentId()+"","autoCardId",card.getAutoCardId()+"");

}
/***********************************************************/
@Override
public void delete(Card card) throws Exception
{
super.delete(className,"autoCardId",card.getAutoCardId()+"");
}
/***********************************************************/
@Override
public Card retrieve(String conditionField,String conditionValue) throws Exception
{
Card card=(Card) super.retreive(className,conditionField,conditionValue);
return card;
}
/***********************************************************/
@Override
public Card[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Card[] card;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
card=new Card[obj.length];
for(int i=0;i<card.length;i++)
{
card[i]=(Card) obj[i];
}
return card;
}
/***********************************************************/
@Override
public Card[] retrieveAll() throws Exception
{
Card[] card;
Object[] obj=super.retreiveAll(className);
card=new Card[obj.length];
for(int i=0;i<card.length;i++)
{
card[i]=(Card) obj[i];
}
return card;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoCardId") ;
	 return key;
}
}
